<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;

class AdminRoleRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        return [
            'name' => 'required|unique:roles,name',
            'title' => 'required',
        ];
    }

    //如果不满足上面的规则,给出的提示信息
    public function messages()
    {
        return [
            'name.required' => '角色标示名称不能为空',
            'name.unique' => '角色表示名称不能重复',
            'title.required' => '角色中文描述不能为空',
        ];
    }
}
